package Services

import (
	"Ahq/Models"
	"Ahq/ValiEngine"
)

type PaperConfig struct {
	Models.Paper
	FormulaConfig FormulaConfig
	Size          int
	Rules         []string
}

func GeneratePaper(paperConfig *PaperConfig) Models.Paper {
	var paper Models.Paper
	paper.SubTitle = paperConfig.SubTitle
	paper.Title = paperConfig.Title
	if paperConfig.Size <= 0 {
		paperConfig.Size = 100
	}
	var num = 1
	rules := ValiEngine.GetCalcRulesByName(paperConfig.Rules)
	for num <= paperConfig.Size {
		formula := GenerateFormula(&paperConfig.FormulaConfig)
		if ValiEngine.Vali(formula.Formula, rules...) {
			paper.Put(&formula)
			num++
		}
	}
	return paper
}
